<!--************************************************************************************************-->
<!-- < searchResult.php >                                                                               -->
<!-- Copyright (c) 2012-2013 San Yat-sun University School of Software                              -->
<!-- Founder: Xiaoxin Mo                                                                           -->
<!-- Stu : 10389159                                                                                 -->
<!-- Date: 2012-01-01                                                                               -->
<!-- Destription : 搜索结果，暂时只能通过全名来得到结果          -->
<!--                                                                                        -->
<!-- Version : 2.1                                                                                  -->
<!--************************************************************************************************-->

<!DOCTYPE html>
<?php
	//include_once("header.php");
	//include_once("bottom.php");
	include_once("../manager/BookManager.php");
	include_once("../manager/ThesisManager.php");
	include_once("../manager/GroupManager.php");
	include_once("../manager/UserManager.php");
?>
<html lang="zh-hk">
	<?php
		
		if (isset($_POST["search_type"])){
			if ( $_POST["search"] != null){
				$search_type = $_POST["search_type"];
				$search_value = $_POST["search"];
				$url = "";
				$exist = false;
			
				// 1- book, 2- group, 3- thesis, 4- user
				switch($search_type)
				{
				case 1:
					$exist = BookManager::getInstance()->exist($search_value);
					
					if ($exist)
						$url = "bookPage.php?book_name=".$search_value;
					break;
				case 2:
					$exist = GroupManager::getInstance()->exist($search_value);
					
					if ($exist)
						$url = "groupPage.php?group_name=".$search_value;
					break;
				case 3:
					$exist = ThesisManager::getInstance()->exist($search_value);
					
					if ($exist)
						$url = "thesisPage.php?thesis_name=".$search_value;
					break;
				case 4:
					$exist = UserManager::getInstance()->exist($search_value);
					
					if ($exist)
						$url = "userPage.php?user_name=".$search_value;
					break;
				default:
					break;
				}
			}
		}
	?>
	
	<head>
		<title>TINY bOOk</title>
		<meta http-equiv="content-type" content="text/html;charset=UTF-8">
		<meta name="contentType" value="text/html  charset=GBK">
		<link rel="stylesheet" type="text/css" href="../css/result.css"/>
		<link rel="shortcut icon" href="images/shortcut.jpg"/>
		<?php
			if (!($url == "")){		
		?>
				<meta http-equiv="refresh" content="1; url=<?=$url?>">
		<?php
			}
			else{
		?>
				<!--<meta http-equiv="refresh" content="1; url=mainpage.php">-->
		<?php
			}
		?>
	</head>	
		
	<body>
		<div id="result">
			<?php
				if (!($url == "")){		
			?>
					<p>搜到结果，跳转到页面</p>
			<?php
				}else{
			?>
					<p>找不到结果，返回主页</p>
			<?php
				}
			?>	
		</div>
	</body>
</html>